package com.dt76.smallloanbackendservice.controller.lhuaw;

import com.dt76.smallloanbackendservice.pojo.lhuaw.AdvertisingManagement;
import com.dt76.smallloanbackendservice.service.lhuaw.AdvertisingManagementService;
import com.dt76.smallloanbackendservice.utils.Page;
import com.dt76.smallloanbackendservice.utils.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/lhuaw")
public class AdvertisingManagementController {
    @Resource
    private AdvertisingManagementService advertisingManagementService;
    @RequestMapping("/qryAllAdvert")
    @ResponseBody
    public List<AdvertisingManagement> AdvertisingManagement1(){
        return advertisingManagementService.qryAllAdvert();
    }
    @RequestMapping("/qryConditionPageAllAdvertising")
    @ResponseBody
    public Page getConditionPageAllAdvertising(@RequestParam("pageIndex")  int pageIndex,
                                               @RequestParam("advertisingName") String advertisingName,
                                               @RequestParam("advertisingLocation") String advertisingLocation){
        System.out.println("成功调用远程");
        return advertisingManagementService.getConditionPageAllAdvertising(pageIndex, advertisingName, advertisingLocation);
    }

    //删除
    @RequestMapping("/delAdvertising")
    @ResponseBody
    public Result delAdvertising(@RequestParam("advId")int advId){
        System.out.println("AdvertisingManagementController.advId>>>>>>>>>");
        try {
            advertisingManagementService.delAdvertising(advId);
            return new Result(true,"删除成功>>>>>");
        } catch (Exception e) {
            return new Result(false,"删除失败>>>>");
        }
    }
}
